// -----------------------------------------------------------------------
//  <copyright file="IApiResultExceptionHandler.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/8 3:02:06</last-date>
// -----------------------------------------------------------------------

using Microsoft.AspNetCore.Mvc.Filters;

namespace DaprPlus.AspNetCore.Mvc.Filters;

/// <summary>
/// API结果异常处理器接口
/// </summary>
public interface IApiResultExceptionHandler
{
    /// <summary>
    /// 判断是否能处理指定的异常
    /// </summary>
    /// <param name="exception">异常对象</param>
    /// <returns>是否能处理</returns>
    bool CanHandle(Exception exception);

    /// <summary>
    /// 处理异常
    /// </summary>
    /// <param name="exception">异常对象</param>
    /// <param name="context">Action执行上下文</param>
    /// <returns>是否已处理异常</returns>
    bool Handle(Exception exception, ActionExecutedContext context);

    /// <summary>
    /// 处理器优先级，数值越小优先级越高
    /// </summary>
    int Priority { get; }
}
